package com.gjl.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gjl.common.annotation.Log;
import com.gjl.common.core.controller.BaseController;
import com.gjl.common.core.domain.AjaxResult;
import com.gjl.common.enums.BusinessType;
import com.gjl.system.domain.FyContent;
import com.gjl.system.service.IFyContentService;
import com.gjl.common.utils.poi.ExcelUtil;
import com.gjl.common.core.page.TableDataInfo;

/**
 * 内容管理Controller
 * 
 * @author ruoyi
 * @date 2025-11-12
 */
@RestController
@RequestMapping("/system/content")
public class FyContentController extends BaseController
{
    @Autowired
    private IFyContentService fyContentService;

    /**
     * 查询内容管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:content:list')")
    @GetMapping("/list")
    public TableDataInfo list(FyContent fyContent)
    {
        startPage();
        List<FyContent> list = fyContentService.selectFyContentList(fyContent);
        return getDataTable(list);
    }

    /**
     * 导出内容管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:content:export')")
    @Log(title = "内容管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FyContent fyContent)
    {
        List<FyContent> list = fyContentService.selectFyContentList(fyContent);
        ExcelUtil<FyContent> util = new ExcelUtil<FyContent>(FyContent.class);
        util.exportExcel(response, list, "内容管理数据");
    }

    /**
     * 获取内容管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:content:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fyContentService.selectFyContentById(id));
    }

    /**
     * 新增内容管理
     */
    @PreAuthorize("@ss.hasPermi('system:content:add')")
    @Log(title = "内容管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FyContent fyContent)
    {
        return toAjax(fyContentService.insertFyContent(fyContent));
    }

    /**
     * 修改内容管理
     */
    @PreAuthorize("@ss.hasPermi('system:content:edit')")
    @Log(title = "内容管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FyContent fyContent)
    {
        return toAjax(fyContentService.updateFyContent(fyContent));
    }

    /**
     * 删除内容管理
     */
    @PreAuthorize("@ss.hasPermi('system:content:remove')")
    @Log(title = "内容管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fyContentService.deleteFyContentByIds(ids));
    }
}
